package vn.info.vietnaminfo.dialog;

import vn.info.vietnaminfo.R;
import vn.info.vietnaminfo.VietNamInfoActivity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.provider.Settings;
import android.view.View;

public class ShowDialog extends View
{
	private Context mContext;
	private AlertDialog.Builder builder;
	
	public ShowDialog(Context context)
	{
		super(context);
		mContext = context;
	}
	
	public void ThongBaoThoatKhoiUngDung(Activity activity)
	{
		final Activity mActivity = activity;
		builder = new AlertDialog.Builder(mContext);
        builder.setTitle(R.string.exit_title);
		builder.setMessage(R.string.exit_message)
        .setPositiveButton(R.string.txt_OK, new DialogInterface.OnClickListener()
        {
        	public void onClick(DialogInterface dialog, int id)
        	{
        		mActivity.finish();
            }
        })
        .setNegativeButton(R.string.txt_huy, new DialogInterface.OnClickListener()
        {
        	public void onClick(DialogInterface dialog, int id)
        	{
        		dialog.cancel();
            }
        });
		builder.show();
	}
	
	public void settingNetwork(Activity activity)
	{
		final Activity mActivity = activity;
		builder = new AlertDialog.Builder(mContext);
		builder.setTitle(R.string.txt_tieude_dulieudidong);
		builder.setMessage(R.string.txt_noidung_dulieudidong)
		.setPositiveButton(R.string.txt_cai_dat, new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				Intent myIntent = new Intent(Settings.ACTION_SETTINGS);
				mContext.startActivity(myIntent);
			}
		})
		.setNegativeButton(R.string.txt_huy, new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				dialog.cancel();
				mActivity.finish();
			}
		});
		builder.show();
	}
	
	public void ThongBaoCaiDatMang()
	{
		builder = new AlertDialog.Builder(mContext);
        builder.setTitle(R.string.txt_tieude_dulieudidong);
		builder.setMessage(R.string.txt_noidung_dulieudidong)
        .setPositiveButton(R.string.txt_cai_dat, new DialogInterface.OnClickListener()
        {
        	public void onClick(DialogInterface dialog, int id)
        	{
        		Intent myIntent = new Intent(Settings.ACTION_SETTINGS);
        		mContext.startActivity(myIntent);
            }
        })
        .setNegativeButton(R.string.txt_huy, new DialogInterface.OnClickListener()
        {
        	public void onClick(DialogInterface dialog, int id)
        	{
        		dialog.cancel();
            }
        });
		builder.show();
	}
	
	public void ThongBaoSuDungViTriGPS()
	{
		String[] ITEMS = new String[] { mContext.getString(R.string.txt_bat_dichvu_dinhvi), mContext.getString(R.string.txt_sudung_vitri_tp) };
		builder = new AlertDialog.Builder(mContext);
        builder.setTitle(R.string.txt_tieude_dichvudinhvi)
		.setItems(ITEMS, new DialogInterface.OnClickListener()
		{
            public void onClick(DialogInterface dialog, int index) 
            {
	            switch(index)
	            {
	            	case 0:
	            		Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
	            		mContext.startActivity(myIntent);
	            		break;
	            	case 1:
	            		((VietNamInfoActivity)mContext).ShowDanhSanhChonTP();
	            		break;
	            }
            }
		})
        .setNegativeButton(R.string.txt_huy, new DialogInterface.OnClickListener()
        {
        	public void onClick(DialogInterface dialog, int id)
        	{
        		dialog.cancel();
            }
        });
		builder.show();
	}
}